home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / dev / misc / diskreader.lha / readturr3disk.asm < prev   
Encoding:
Assembly Source File  |  2000-02-21  |  1.9 KB  |  87 lines

  1. NO_INCLUDES=1
  2. MESSAGES=1
  3.     include    adfreader.asm
  4.  
  5. ; track 0: dos track (5632 bytes)
  6.  
  7.     WRITEDOS #0
  8.  
  9. ; track 1:
  10. ; - $4489 MFM sync
  11. ; - $2aaa MFM ID
  12. ; - 6144 bytes of data (1536 * 8-byte MFM encoded longwords)
  13. ; - longword checksum (1 * 8-byte MFM encoded longword)
  14.  
  15. ; tracks 2-159 except track 43:
  16. ; - $4489 MFM sync
  17. ; - $2aa5 MFM ID
  18. ; - cylinder number, eg 1-79 (1 * 4-byte MFM encoded word)
  19. ; - 6656 bytes of data (1664 * 8-byte MFM longwords)
  20. ; - longword checksum (1 * 8-byte MFM longword)
  21.  
  22. ; track 43:
  23. ; - $4489 MFM sync
  24. ; - $2aa5 MFM ID
  25. ; - 6144 bytes of data (1536 * 8-byte MFM encoded longwords)
  26. ; - longword checksum (1 * 8-byte MFM encoded longword)
  27.  
  28. ; checksums of tracks are coded by longword adds of all decoded data
  29.  
  30. ; The WHD slave uses reversed disk-sides from track 2 onwards, so the
  31. ; track saving order is 0, 1, 3,2, 5,4, 7,6, 9,8, ...
  32.  
  33. GETMFM    MACRO    ; gets one mfm longword
  34.     movem.l    (a1)+,d1/d2
  35.     and.l    d4,d1
  36.     and.l    d4,d2
  37.     add.l    d1,d1
  38.     or.l    d2,d1
  39.     ENDM
  40.  
  41.     move.l    #$55555555,d4    ; d4 = 0101010101010...
  42.     moveq    #0,d7        ; d7 = track
  43.  
  44. .nxttrk    move.l    d7,d1
  45.     eori.b    #1,d1
  46.     RAWREAD    d1
  47.     RESYNC    #$4489
  48.  
  49.     lea    __trk,a0    ; beginning of buffer
  50.     move.l    a0,a1        ; find beginning of data in buffer
  51. .again    cmp.w    #$4489,(a1)+    ; and skip first word ($2aa5/$2aaa)
  52.     beq.s    .again
  53.  
  54.     cmp.b    #0,d7        ; tracks 1 and 43 are different to the rest
  55.     beq.s    .shrtrk
  56.     cmp.b    #42,d7
  57.     beq.s    .shrtrk
  58.     addq    #4,a1
  59.  
  60.     move.w    #(6656/4)-1,d0
  61.     bra.s    .cont
  62. .shrtrk    move.w    #(6144/4)-1,d0
  63. .cont
  64.     moveq    #0,d3        ; accumulated checksum
  65. .decode    GETMFM
  66.     move.l    d1,(a0)+    ; write long
  67.     add.l    d1,d3        ; checksum decoded data
  68.     dbra    d0,.decode
  69.     GETMFM            ; get stored checksum
  70.     cmp.l    d1,d3        ; verify checksum
  71.     bne.s    .fail
  72.  
  73.     move.l    #6656,d1
  74.     cmp.b    #0,d7        ; track 1 = 6144 bytes
  75.     bne.s    .ntrk1
  76.     addq.b    #1,d7        ; next track = 3 (then 2, 5, 4, 7, 6...)
  77.     move.w    #6144,d1
  78. .ntrk1    WRITE    d1        ; save to diskfile
  79.  
  80.     addq.w    #1,d7
  81.     cmp.w    #160,d7
  82.     bne    .nxttrk
  83.     rts
  84.  
  85. .fail    FAILURE    cksum(pc)
  86. cksum    dc.b    'bad checksum',0
  87.